<%@ page contentType="text/html;charset=UTF-8" %>

<!DOCTYPE html>
<html>
<head>
	<title>附件库注册信息新增/修改</title>
	<%@ include file="/common/meta.jsp" %>
	<%@ include file="/common/import.jsp" %>
	<script type="text/javascript" src="${ctx}/js/zbxtools.js"></script>
	<script type="text/javascript" src="${ctx}/js/easyui/extendvalidate.js"></script>
	<script type="text/javascript">
		var inputForm = '#inputForm';
		$(function(){
			$('#inputForm').form({
			    success:function(data){
			    	var result = jQuery.parseJSON(data);
			    	if(result.flag=='T'){
			    		$.messager.alert('提交结果', '操作成功', 'info',function(){
			    		    parent.colseAdd();//关闭窗口
			    		    parent.attaRegReload();
			    		});
			    	}else{
			    		$.messager.alert('提交结果', '操作失败:'+result.msg, 'error');
			    	}        
			    },
				error: function(messg){
					$.messager.alert('错误提示', '操作失败:'+messg.responseText, 'error');
				}
			});
		
			clickAttaSort();
		});
		
		function doSubmit(){
			var flag = $(inputForm).form('validate');
			
			if(flag){
				//ZBXTools.showProcess('正在提交数据...');
				$(inputForm).submit();
			}
		}
		
	function clickAttaSort() {
		var attaSort = $("input[name='attaSort']:checked").val();
		if (attaSort == '0') {
			
			$("#pictr1").hide();
			$("#pictr2").hide();
			$("#pictr3").hide();
			$("#pictr4").hide();
			$("#pictr5").hide();
      
            $("#smallWidth").attr("data-options","required:false");
            $("#smallWidth").removeAttr("class");
            
	   		 $("#smallHeight").attr("data-options","required:false");
	   		 $("#smallHeight").removeAttr("class");
     		  
            $("#middleWidth").attr("data-options","required:false");
            $("#middleWidth").removeAttr("class");
             
            $("#middleHeigth").attr("data-options","required:false");
            $("#middleHeigth").removeAttr("class");
            
            $("#fileSpan").show();
            $("#picSpan").hide();
		} else {
		
			$("#pictr1").show();
			$("#pictr2").show();
			$("#pictr3").show();
			$("#pictr4").show();
			$("#pictr5").show();
			
			$("#smallWidth").attr("data-options","required:true");
			$("#smallWidth").attr("class","easyui-numberbox numberbox-f validatebox-text");
            $("#smallHeight").attr("data-options","required:true");
            $("#smallHeight").attr("class","easyui-numberbox numberbox-f validatebox-text");
            $("#middleWidth").attr("data-options","required:true");
            $("#middleWidth").attr("class","easyui-numberbox numberbox-f validatebox-text");
            $("#middleHeigth").attr("data-options","required:true");
            $("#middleHeigth").attr("class","easyui-numberbox numberbox-f validatebox-text");
			
			$("#fileSpan").hide();
            $("#picSpan").show();
     	}
		
	}
	</script>
	
	<style type="text/css">	body{font-size:12px;} </style>
</head>
<body>
<div id="tip"></div>
	<form id="inputForm" name="inputForm" method="post" action="${ctx}/attachment/register/save.action">
		<input type="hidden" name="formToken" id="formToken" value="${formToken}"/>
		<input type="hidden" name="rid" id="rid" value="${register.rid}"/>
		<table class="datagrid-body" >
			<tr>
				<td class="datagrid-header" colspan="2">
				<c:if test="${empty register.attaSort || register.attaSort eq null }">  
				   <input type="radio" name="attaSort" value="0"  checked=checked onclick="clickAttaSort()" />&nbsp;附件
				   <input type="radio" name="attaSort" value="1" onclick="clickAttaSort()" />&nbsp;图片
				</c:if>
				<c:if test="${not empty register.attaSort && register.attaSort ne null }">
				    <c:if test="${register.attaSort eq '0'}">附件</c:if>
				    <c:if test="${register.attaSort eq '1'}">图片</c:if>
				   <input type="radio" name="attaSort" style="display: none" readonly="readonly" value="0" <c:if test="${register.attaSort eq '0'}"> checked=checked </c:if> onclick="clickAttaSort()" />
				   <input type="radio" name="attaSort" style="display: none" readonly="readonly" value="1" <c:if test="${register.attaSort eq '1'}"> checked=checked </c:if> onclick="clickAttaSort()" />
				</c:if>
				</td>				
			</tr>
			<tr>
				<td class="datagrid-header" width="25%">注册英文标示<font color=red>*</font></td>
				<td>
					<input id="regEname" name="regEname"  value="${register.regEname}"  onkeyup="value=value.replace(/[^\a-\z\A-\Z]/g,'')"
					class="easyui-validatebox" data-options="required:true,validType:'length[1,100]'" size="40"  
					missingMessage="注册英文标示" invalidMessage="应为1~100个英文字符" />
				</td>
			</tr>
			<tr >
				<td class="datagrid-header">注册中文名称<font color=red>*</font></td>
				<td>
					<input name="regCname"  id="regCname" value="${register.regCname}" 
					class="easyui-validatebox" data-options="required:true,validType:'length[1,100]',validType:'CHS'" size="40" 
					missingMessage="注册中文名称" invalidMessage="应为1~100个汉字" />				
				</td>
			</tr>
			<tr >
				<td class="datagrid-header">上传数量<font color=red>*</font></td>
				<td>
					<input name="picTotalNum"  id="picTotalNum" value="${register.picTotalNum}" min="0" max="99999"
					class="easyui-numberbox" data-options="required:true" size="40"   />&nbsp;&nbsp;如果为0，则不限制上传数量！				
				</td>
			</tr>
			
			<tr id="pictr1" >
				<td class="datagrid-header">小图尺寸<font color=red>*</font></td>
				<td>
					<input name="smallWidth" id="smallWidth" value="${register.smallWidth}" class="easyui-numberbox" data-options="required:true"  min="1" max="99999" type=text size=4 />(宽度)
					<input name="smallHeight" id="smallHeight" value="${register.smallHeight}" class="easyui-numberbox" data-options="required:true"  min="1" max="99999" type=text size=4 />(高度)
				</td>
			</tr>			
			<tr id="pictr2" >
				<td class="datagrid-header">中图尺寸<font color=red>*</font></td>
				<td>
					<input name="middleWidth" id="middleWidth" value="${register.middleWidth}" class="easyui-numberbox" data-options="required:true" min="1" max="99999" type=text size=4>(宽度)
					<input name="middleHeigth" id="middleHeigth" value="${register.middleHeigth}" class="easyui-numberbox" data-options="required:true" min="1" max="99999" type=text size=4>(高度)
				</td>
			</tr>			
			<tr id="pictr3" style="display:none">
				<td class="datagrid-header">水印图片路径：</td>
				<td>
					<input id="watermarkFile" name="watermarkFile"  value="${register.watermarkFile}"
					class="easyui-validatebox"  data-options="required:false,validType:'length[0,1000]'" size="40" 
					missingMessage="水印图片路径" invalidMessage="最多1000个字符" />
				</td>
			</tr>			
			<tr id="pictr4" style="display:none">
				<td class="datagrid-header">水印图片坐标：</td>
				<td>
					
					<input name="wmX" id="wmX" class="easyui-numberbox" type=text size=4 value="${register.wmX}" />&nbsp;&nbsp;X
					<input name="wmY" id="wmY" class="easyui-numberbox" type=text size=4 value="${register.wmY}" />&nbsp;&nbsp;Y
				</td>
			</tr>			
			<tr id="pictr5" style="display:none">
				<td class="datagrid-header">水印图片透明度：</td>
				<td>
					<input id="wmFilter" name="wmFilter"  value="${register.wmFilter}" min="0" max="1" 
					class="easyui-numberbox"  precision="2" size="10" data-options="required:false"  type=text /><span id="wmFilterSpan">&nbsp;&nbsp;[0.00~1.0]</span>
				</td>
			</tr>			
			
			
			
			<tr>
				<td class="datagrid-header">允许的文件类型<font color=red>*</font>:</td>
				<td>
					<input id="alloweTypes" name="alloweTypes"  value="${register.alloweTypes}"
					class="easyui-validatebox" size="10" data-options="required:true,validType:'length[3,30]'" 
					missingMessage="允许的文件类型" invalidMessage="应为3~30个字" />&nbsp;&nbsp;<span id="picSpan" style="display:none">*.*表示全部文件类型,如果需要指定具体文件类型,格式为*.png;*.gif;*.jpg;</span><span id="fileSpan">*.*表示全部文件类型,如果需要指定具体文件类型,格式为*.zip;*.doc;*.rar;</span>
				</td>
			</tr>			
			<tr>
				<td class="datagrid-header">文件大小限制<font color=red>*</font></td>
				<td>
					<input id="maxLength" name="maxLength"  value="${register.maxLength}"  min="10"  data-options="required:true"
					class="easyui-numberspinner" missingMessage="文件大小限制" size="20" />&nbsp;KB
				</td>
			</tr>
			<tr>
				<td class="datagrid-header">ip地址使用限制：</td>
				<td>
					<input id="ipAddress" name="ipAddress"  value="${register.ipAddress}"
					class="easyui-validatebox" size="40" data-options="required:false,validType:'length[2,100]'" 
					missingMessage="描述" invalidMessage="应为2~100个字" />
				</td>
			</tr>			
			<!--<tr>
				<td class="datagrid-header">写权限级别：</td>
				<td>
					<select name="writeControlLevel" id="writeControlLevel" value="${register.writeControlLevel}" class="easyui-combobox" editable="editable" data-options="panelHeight:'auto'">
							<option value="1">不需要登录用</option>
							<option value="2">登录即可以用	</option>
							<option value="3">登录必须有相应权限才能用</option>
						</select>
				</td>
			</tr>			
			<tr>
				<td class="datagrid-header">写权限key：</td>
				<td>
					<input id="writeKey" name="writeKey"  value="${register.writeKey}"
					class="easyui-validatebox" size="40" data-options="required:false,validType:'length[2,30]'" 
					missingMessage="描述" invalidMessage="应为2~30个字" />
				</td>
			</tr>			
			<tr>
				<td class="datagrid-header">读权限级别：</td>
				<td>
					<select name="readControlLevel" id="readControlLevel" value="${register.readControlLevel}" class="easyui-combobox" editable="editable" data-options="panelHeight:'auto'">
							<option value="1">不需要登录用</option>
							<option value="2">登录即可以用	</option>
							<option value="3">登录必须有相应权限才能用</option>
					</select>
				</td>
			</tr>			
			<tr>
				<td class="datagrid-header">读权限key：</td>
				<td>
					<input id="readKey" name="readKey"  value="${register.readKey}"
					class="easyui-validatebox" size="40" data-options="required:false,validType:'length[2,30]'" 
					missingMessage="描述" invalidMessage="应为2~30个字" />
				</td>
			</tr>		-->	
			
			
			<tr>
				<td class="datagrid-header"></td>
				<td >	
					<a href="#" class="easyui-linkbutton" id="bt1" iconCls="icon-save" onclick="doSubmit();">提交</a>
					<a href="#" class="easyui-linkbutton" iconCls="icon-cancel" onclick="parent.colseAdd();"; >取消</a>				
				</td>
			</tr>
		</table>
	</form>

</body>
</html>
